﻿using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace Sizebox.CharacterEditor
{
	// Token: 0x02000256 RID: 598
	public class MaterialEntryGui : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
	{
		// Token: 0x1700017E RID: 382
		// (get) Token: 0x06000CF5 RID: 3317 RVA: 0x000687AC File Offset: 0x000669AC
		// (set) Token: 0x06000CF6 RID: 3318 RVA: 0x000687B4 File Offset: 0x000669B4
		public MaterialWrapper Wrapper { get; private set; }

		// Token: 0x06000CF7 RID: 3319 RVA: 0x000687C0 File Offset: 0x000669C0
		public void RegisterMaterial(MaterialWrapper wrapper, MaterialEditView materialView)
		{
			this.Wrapper = wrapper;
			this.materialView = materialView;
			this.nameText.text = wrapper.Material.name;
			this.nameText.text = this.nameText.text.Replace("(Instance)", string.Empty);
		}

		// Token: 0x06000CF8 RID: 3320 RVA: 0x00068816 File Offset: 0x00066A16
		public void Select()
		{
			this.textBackground.color = this.selectedColor;
			this.nameText.color = this.selectedTextColor;
			this.Selected = true;
		}

		// Token: 0x06000CF9 RID: 3321 RVA: 0x00068841 File Offset: 0x00066A41
		public void Deselect()
		{
			this.textBackground.color = this.normalColor;
			this.nameText.color = this.normalTextColor;
			this.Selected = false;
		}

		// Token: 0x06000CFA RID: 3322 RVA: 0x0006886C File Offset: 0x00066A6C
		void IPointerClickHandler.OnPointerClick(PointerEventData eventData)
		{
			if (!this.materialView)
			{
				return;
			}
			MaterialControlGui controls = this.materialView.GetControls();
			controls.RegisterMaterial(this);
		}

		// Token: 0x04001204 RID: 4612
		[SerializeField]
		[Header("Required References")]
		private Image textBackground;

		// Token: 0x04001205 RID: 4613
		[SerializeField]
		private Text nameText;

		// Token: 0x04001206 RID: 4614
		[SerializeField]
		[Header("Colors")]
		[Space]
		private Color selectedColor;

		// Token: 0x04001207 RID: 4615
		[SerializeField]
		private Color normalColor;

		// Token: 0x04001208 RID: 4616
		[SerializeField]
		private Color selectedTextColor;

		// Token: 0x04001209 RID: 4617
		[SerializeField]
		private Color normalTextColor;

		// Token: 0x0400120A RID: 4618
		public bool Selected;

		// Token: 0x0400120C RID: 4620
		private MaterialEditView materialView;
	}
}
